fix buffer overflow in print XS_DEBUG command
authorvhanquez@kneesa.uk.xensource.com <vhanquez@kneesa.uk.xensource.com>
Wed, 15 Mar 2006 12:24:34 +0000 (12:24 +0000)
committervhanquez@kneesa.uk.xensource.com <vhanquez@kneesa.uk.xensource.com>
Wed, 15 Mar 2006 12:24:34 +0000 (12:24 +0000)
Signed-off-by: Vincent Hanquez <vincent@xensource.com>
tools/xenstore/xenstored_core.c

index 70760468014c0df76812dac25d297c8abfada5fb..afede2f454b7b0997b24c23b37efde0fb9984cb9 100644 (file)
@@ -1115,8 +1115,17 @@ static void do_set_perms(struct connection *conn, struct buffered_data *in)
 
 static void do_debug(struct connection *conn, struct buffered_data *in)
 {
-       if (streq(in->buffer, "print"))
+       int num;
+
+       num = xs_count_strings(in->buffer, in->used);
+
+       if (streq(in->buffer, "print")) {
+               if (num < 2) {
+                       send_error(conn, EINVAL);
+                       return;
+               }
                xprintf("debug: %s", in->buffer + get_string(in, 0));
+       }
        if (streq(in->buffer, "check"))
                check_store();
 #ifdef TESTING